package com.byzk.invoice.xml.Doc_0.Tags;

import com.byzk.invoice.util.DocumentUtil;
import org.dom4j.*;

import java.io.File;

/**
 * 创建CustomTags.xml.
 *
 * @author 康鹏 2020-05-20
 */
public class CustomTags {

    /**
     * 创建Doc_0/Tags/CustomTags.xml.
     * @param customTagsXmlPath CustomTags.xml存放路径
     * @throws Exception Exception
     */
    public static void createCustomTagsXml(String customTagsXmlPath) throws Exception {

        Namespace namespace = new Namespace("ofd", "http://www.ofdspec.org/2016");
        //创建外层<ofd:CustomTags />
        Element rootElt = DocumentHelper.createElement(new QName("CustomTags", namespace));
        //创建<ofd:CustomTag />
        Element customTagElt = rootElt.addElement("ofd:CustomTag");
        customTagElt.addAttribute("TypeID", "fp");
        //创建<ofd:FileLoc />
        Element fileLocElt = customTagElt.addElement("ofd:FileLoc");
        fileLocElt.setText("Tag_Invoice.xml");

        Document document = DocumentHelper.createDocument(rootElt);
        DocumentUtil.writer(document, customTagsXmlPath + File.separator + "Doc_0" + File.separator + "Tags"
                + File.separator + "CustomTags.xml", true);
    }

}
